package com.xzc.java8.C_Collect;

import com.alibaba.fastjson.JSON;

import java.util.ArrayList;
import java.util.List;

import static java.util.stream.Collectors.*;

public class CountTest {

    public static void main(String[] args) {
        List<Apple> list0 = new ArrayList<>();
        Apple a0 = new Apple("a0", "red", 150, 2011);
        Apple a1 = new Apple("a1", "blue", 10, 2012);
        Apple a2 = new Apple("a2", "red", 110, 2011);
        Apple a3 = new Apple("a3", "yellow", 140, 2013);
        list0.add(a0);
        list0.add(a1);
        list0.add(a2);
        list0.add(a3);

        //idea提示的优化建议是直接用list0.size()
        Long out0 = list0.stream().collect(counting());
        System.out.println(out0);
    }
}
